import 'package:search_people/utils/httputils/http_man.dart';

import 'result_data.dart';
import 'urlpath.dart';

class Api {
  //登录
  static Future<NetBaseReponse> login(Map<String, dynamic> param) {
    return HttpMan.instance.post(UrlPath.login, args: param);
  }

  //发送验证码
  static Future<NetBaseReponse> sendCode(Map<String, dynamic> param) {
    return HttpMan.instance.post(UrlPath.sendCode, args: param);
  }

//获取路径
  static Future<NetBaseReponse> getPath(Map<String, dynamic> param) {
    return HttpMan.instance.post(UrlPath.path, args: param);
  }

  //关键词搜索
  static Future<NetBaseReponse> search_list(Map<String, dynamic> param) {
    return HttpMan.instance.post(UrlPath.search_list, args: param);
  }

  //单选搜索
  static Future<NetBaseReponse> searchOption(Map<String, dynamic> param) {
    return HttpMan.instance.post(UrlPath.search_option, args: param);
  }

  //按区域单选搜索
  static Future<NetBaseReponse> searchCity(Map<String, dynamic> param) {
    return HttpMan.instance.get(UrlPath.search_city, args: param);
  }

  //热门人物
  static Future<NetBaseReponse> hot_people() {
    return HttpMan.instance.get(UrlPath.hot_people);
  }

  //人物基本信息
  static Future<NetBaseReponse> getPersonBaseInfo(String id) {
    return HttpMan.instance.get(UrlPath.personBaseInfo, args: {
      'leaderId': id,
    });
  }

  //人物历史
  static Future<NetBaseReponse> getPersonHistory(String id) {
    return HttpMan.instance.get(UrlPath.personHistory, args: {
      'leaderId': id,
    });
  }

  //人物政绩
  static Future<NetBaseReponse> getCharacterMap(String id) {
    return HttpMan.instance.get(UrlPath.personCharacterMap, args: {
      'leaderId': id,
    });
  }

  //人物动态
  static Future<NetBaseReponse> getPersonDynamics(String id) {
    return HttpMan.instance.post(UrlPath.personDynamics, args: {
      'leaderId': id,
      'current': 1,
      'size': 10,
    });
  }

  //城市列表
  static Future<NetBaseReponse> getCityList() {
    return HttpMan.instance.get(UrlPath.city_list);
  }

  //学校列表
  static Future<NetBaseReponse> getSchoolList({
    String? name,
  }) {
    return HttpMan.instance.get(
      UrlPath.school_list,
      args: {'schoolName': name ?? ''},
    );
  }

  //出生年代
  static Future<NetBaseReponse> getBirthdayList() {
    return HttpMan.instance.get(UrlPath.birthday);
  }
}

extension HomeApi on Api {
  //工作动态
  static Future<NetBaseReponse> postDynamicList({
    required int pageIndex,
  }) {
    return HttpMan.instance.post(UrlPath.dynamic_list, args: {
      "current": pageIndex,
      "size": 10,
    });
  }

  //工作动态
  static Future<NetBaseReponse> getJobs() {
    return HttpMan.instance.get(UrlPath.search_job);
  }

  //超级搜索
  static Future<NetBaseReponse> postSuperSearch({
    required List<String> birthDateStrs,
    required List<String> hometownNames,
    required List<String> jobIds,
    required List<String> regionNames,
    required List<String> schoolIds,
    required int pageIndex,
  }) {
    return HttpMan.instance.post(UrlPath.super_search, args: {
      "birthDateStrs": birthDateStrs,
      "current": pageIndex,
      "hometownNames": hometownNames,
      "jobIds": jobIds,
      "regionNames": regionNames,
      "schoolIds": schoolIds,
      "size": 10
    });
  }
}

class MeApi extends Api {
  static Future<NetBaseReponse> versionUpdate() {
    return HttpMan.instance.get(UrlPath.checkUpdate);
  }
}
